<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>重点关注-专项案件</title>
    <link rel="stylesheet" href="/layui/v11/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style>
        #ltTree {
            overflow: auto; /* 添加滚动条 */
            white-space: nowrap; /* 不换行 */
            text-overflow: ellipsis; /* 超出显示省略号 */
            max-height: 100%; /* 限制高度 */
        }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space6">
        <div class="layui-col-xs2">
            <div class="layui-card">
                <div class="layui-card-body" id="ltTree"></div>
            </div>
        </div>
        <div class="layui-col-xs10">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input type="text" id="nsrmc" class="layui-input" autocomplete="off"
                                   placeholder="请输入企业名称">
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" id="nsrsbh" class="layui-input" autocomplete="off"
                                   placeholder="请输纳税人识别号">
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" id="ajbh" class="layui-input" autocomplete="off"
                                   placeholder="请输案件编号">
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select id="jcks"></select>
                        </div>
                        <div class="layui-input-inline ">
                            <button class="layui-btn" onclick="searchAjxx()" id="search">查询
                            </button>
                            <button class="layui-btn" onclick="searchAjxx()" id="exportZxaj">导出
                            </button>
                        </div>
                    </div>
                    <table class="layui-hide" id="ajxx_table" lay-filter="ajxx_table"></table>
                </div>
            </div>
        </div>
        <div class="ajxx_record_div" hidden>
            <table class="layui-hide" id="flowRecord_table" lay-filter="flowRecord_table"></table>
        </div>

        <div class="log_record_div" hidden>
            <table class="layui-hide" id="logRecord_table" lay-filter="logRecord_table"></table>
        </div>
    </div>
</div>


</body>

<script type="text/html" id="ajxxtool">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="ajxxRecord">流转记录</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="logRecord">日志记录</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="createDd">一键调度</a>
</script>

<script type="text/html" id="toolbar_log">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-primary" lay-event="returnBack">返回</button>
    </div>
</script>
<script src="/layui/v11/layui.js"></script>
<script src="/js/core.util.js"></script>
<script language="JavaScript" src="/newmain/js/bizjs/gy.js"></script>
<script>
    var pub_caseId;
    var tableIns1;
    //获取token
    var token = CoreUtil.getData("access_token");
    //地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    let $ = jQuery = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;
    var util = layui.util;
    var admin = layui.admin;
    var tree = layui.tree;

    layui.use(['layer', 'form', 'table', 'util', 'tree'], function () {
        // 左边树
        CoreUtil.sendGet("/attention/attentionCase/tree", null, function (res) {
            let treeData = res.data;
            // 树形渲染
            tree.render({
                elem: '#ltTree',
                data: treeData,
                click: function (obj) {
                    pub_caseId = obj.data.id;
                    searchAjxx();
                    // console.log(obj.data); //得到当前点击的节点数据
                    // console.log("树形点击事件===" + obj.data.id);
                    // console.log("树形点击事件===" + obj.data.title);
                }
            });
        });
        //加载table
        tableIns1 = table.render({
            elem: '#ajxx_table'
            , contentType: 'application/json'
            , headers: {"authorization": token}
            , page: true //开启分页
            , where: {caseId: '000'}
            , url: '/attention/specialCaseManagement/listajxx' //数据接口
            , method: 'POST'
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表
                }
            }
            , cols: [
                [
                    {field: 'jcajxxuuid', title: '金三案件信息表主键', width: 0, hide: true},
                    {field: 'ajbh', title: '案件编号', width: 200, align: 'center', sort: true},
                    {field: 'nsrsbh', title: '纳税人识别号', width: 200, align: 'center', sort: true},
                    {field: 'nsrmc', title: '纳税人名称', width: 280, align: 'center', sort: true},
                    {field: 'ajjcztDm', title: '金三状态', width: 120, align: 'center', sort: true},
                    {field: 'sjzt', title: '实际状态', width: 120, align: 'center', sort: true},
                    {field: 'xpnd', title: '下派年度', width: 140, align: "center", sort: true},
                    {field: 'dbcj', title: '督办层级', width: 140, align: "center", sort: true},
                    {field: 'ajssdl', title: '案件所属大类', width: 240, align: "center", sort: true},
                    {field: 'aymc', title: '案源名称', width: 180, align: "center", sort: true},
                    {field: 'jcks', title: '检查科室', width: 300, align: 'center', sort: true},
                    {field: 'jcr', title: '检查人', width: 220, align: 'center', sort: true},
                    {field: 'slry', title: '审理人', width: 220, align: 'center', sort: true},
                    {field: 'zxry', title: '执行人', width: 220, align: 'center', sort: true},
                    {
                        field: 'larq',
                        title: '立案日期',
                        width: 140,
                        align: "center",
                        sort: true,
                        templet: function (d) {
                            if (!d.larq) {
                                return '';
                            }
                            return layui.util.toDateString(d.larq, 'yyyy-MM-dd');
                        }
                    }, {field: 'lats', title: '立案天数', width: 140, align: 'center', sort: true},
                    {
                        field: 'cbe',
                        title: '查补额',
                        width: 140,
                        align: 'center',
                        sort: true,
                        templet: function (d) {
                            // 确保数据是数字，并保留2位小数
                            return parseFloat(d.cbe).toFixed(2);
                        }
                    },
                    {
                        field: 'rke',
                        title: '入库额',
                        width: 140,
                        align: 'center',
                        sort: true,
                        templet: function (d) {
                            // 确保数据是数字，并保留2位小数
                            return parseFloat(d.rke).toFixed(2);
                        }
                    },
                    {
                        field: 'createTime',
                        title: '案件导入日期',
                        width: 140,
                        align: "center",
                        sort: true,
                        templet: function (d) {
                            if (!d.createTime) {
                                return '';
                            }
                            return layui.util.toDateString(d.createTime, 'yyyy-MM-dd');
                        }
                    },
                    {toolbar: '#ajxxtool', title: '操作', width: 240, align: 'center', fixed: 'right'}
                ]
            ]
            , toolbar: '#toolbar'
        });
        //案件列表 - 按钮
        table.on('tool(ajxx_table)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'ajxxRecord':
                    //加载flowrecord
                    table.render({
                        elem: '#flowRecord_table'
                        , contentType: 'application/json'
                        , headers: {"authorization": token}
                        , where: {relevance: data.jcajxxuuid}
                        , url: '/attention/attentionCase/flowRecord' //数据接口
                        , method: 'POST'
                        , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                            return {
                                "code": res.code, //解析接口状态
                                "msg": res.msg, //解析提示文本
                                "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                                "data": CoreUtil.isEmpty(res.data) ? null : res.data //解析数据列表
                            }
                        }
                        , cols: [
                            [
                                {field: 'category', title: '类型', width: 250, align: 'center'},
                                {field: 'date', title: '日期', width: 120, align: 'center'},
                                {field: 'czr', title: '操作人', width: 140, align: 'center'},
                                {field: 'ajbh', title: '案件编号', width: 200, align: 'center'},
                                {field: 'nsrmc', title: '企业名称', width: 250, align: 'center'},
                                {field: 'czsj', title: '操作时间', width: 120, align: 'center'},
                                {field: 'bz', title: '内容', width: 250, align: 'center'},

                            ]
                        ]
                        , toolbar: '#toolbar'
                    });
                    $(".ajxx_record_div").show();
                    $(".layui-fluid").hide();
                    break;
                case 'logRecord':
                    //日志记录
                    skipOpen("/index/statistics/ajlogrecord?relevance=" + data.jcajxxuuid, "11001", "日志记录");
                    break;
            }
        });
        //流转记录 - 按钮
        table.on('toolbar(flowRecord_table)', function () {
            $(".ajxx_record_div").hide();
            $(".layui-fluid").show();
        });
        //日志记录 - 按钮
        table.on('toolbar(logRecord_table)', function () {
            $(".log_record_div").hide();
            $(".layui-fluid").show();
        });
        //初始化检查科室查询条件
        CoreUtil.sendPost("/attention/gy/getcurrentswjgjcks", null, function (res) {
            let datas = res.data;
            let options = "<option value = '00'>请选择检查科室</option><option value = '00'>全局</option>";
            for (let i = 0; i < datas.length; i++) {
                options += '<option value="' + datas[i].swjgDm + '">' + datas[i].swjgjc + '</option>';
            }
            $('#jcks').append(options);
            // 更新select渲染
            form.render('select');
        });
        // 导出
        $("#exportZxaj").click(function () {
            layer.confirm('确定导出所有数据?', {icon: 3, title: '提示'}, function (index) {
                let mapArr = {
                    caseId: pub_caseId,
                    nsrmc: $("#nsrmc").val(),
                    nsrsbh: $("#nsrsbh").val(),
                    ajbh: $("#ajbh").val(),
                    jcks: $("#jcks").val(),
                };
                CoreUtil.sendPost("/attention/specialCaseManagement/exportZxaj", mapArr, function (res) {
                    if (res.code === 0) {
                        const data = res.data;
                        if (!CoreUtil.isEmpty(data)) {
                            //全部导出
                            table.exportFile(tableIns1.config.id, data, 'xlsx', "专项案件")
                        } else {
                            layer.alert('未查询到需要导出的数据！', {icon: 2});
                        }
                    }
                });
                layer.close(index);
            });
            return false; // ✅ 用这个阻止默认行为
        })

    });

    //案件列表查询
    function searchAjxx() {
        tableIns1.reload({
            where: { //设定异步数据接口的额外参数，任意设
                caseId: pub_caseId,
                nsrmc: $("#nsrmc").val(),
                nsrsbh: $("#nsrsbh").val(),
                ajbh: $("#ajbh").val(),
                jcks: $("#jcks").val(),
            }
            , page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }
</script>
</html>